<template>
    <div class="search">
        <Row>
            <Col>
                <Card>
                    <Row>
                        <Form ref="searchForm" :model="searchForm" inline :label-width="90">
                            <Form-item label="见证人姓名" prop="qualityId">
                                <Input type="text" v-model="searchForm.witnessName" clearable placeholder="请输入"
                                       style="width: 200px"/>
                            </Form-item>
                            <Form-item label="证件号码" prop="qualityName">
                                <Input type="text" v-model="searchForm.witnessIdCard" clearable placeholder="请输入"
                                       style="width: 200px"/>
                            </Form-item>
                            <Form-item label="合作商名称" prop="channelFullName">
                                <Input type="text" v-model="searchForm.channelFullName" clearable placeholder="请输入"
                                       style="width: 200px"/>
                            </Form-item>
                            <Form-item style="margin-left:-60px;" class="br">
                                <Button @click="handleSearch" type="success" icon="ios-search">搜索</Button>
                            </Form-item>
                        </Form>
                    </Row>
                </Card>
            </Col>
        </Row>
        <Row>
            <Table :loading="loading" border :columns="columns" :data="data" sortable="custom" ref="table">
                <!--状态:00 已启动  01 审核中  02 草稿  03 退回  04 拒绝  05 停用-->
                <template slot-scope="{ row }" slot="status">
                    <div v-if="row.status === '00'">
                        <Tag color="green">已启动</Tag>
                    </div>
                    <div v-if="row.status === '01'">
                        <Tag color="yellow">审核中</Tag>
                    </div>
                    <div v-if="row.status === '02'">
                        <Tag color="yellow">草稿</Tag>
                    </div>
                    <div v-if="row.status === '03'">
                        <Tag color="yellow">退回</Tag>
                    </div>
                    <div v-if="row.status === '04'">
                        <Tag color="red">拒绝</Tag>
                    </div>
                    <div v-if="row.status === '05'">
                        <Tag color="grey">停用</Tag>
                    </div>
                </template>
                <!--业务属性 二手车:1、多品新车:0-->
                <template slot-scope="{ row }" slot="businessType">
                    <div v-if="row.businessAttributes === '0'">
                        <label>多品新车</label>
                    </div>
                    <div v-if="row.businessAttributes === '1'">
                        <label>二手车</label>
                    </div>
                </template>
            </Table>
        </Row>
        <Row type="flex" justify="end" class="page">
            <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize"
                  @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]"
                  size="small" show-total show-elevator show-sizer></Page>
        </Row>
    </div>
</template>

<script>
    import {getWitnessList} from '_p/afs-core-business/api/afs-case/loan-approve/loanAuditWitness'
    export default {
        name: "loanAuditWitness",
        props: {
            detailParams: {}
        },
        data(){
            return{
                loading: true,
                searchForm: {
                    witnessName: "",
                    witnessIdCard: "",
                    channelFullName: "",
                    pageNumber: 1,
                    pageSize: 10
                },
                columns: [
                    {
                        title: "见证人姓名",
                        key: "witnessName",
                        align: "center",
                    },
                    {
                        title: "证件号码",
                        key: "witnessIdCard",
                        align: "center",
                    },
                    {
                        title: "合作商名称",
                        key: "channelFullName",
                        align: "center",
                    },
                    {
                        title: "业务类型",
                        key: "qualityStatusIn",
                        slot: 'businessType',
                        align: "center",
                    },
                    {
                        title: "联系方式",
                        key: "witnessContactNumber",
                        align: "center",
                    },
                    {
                        title: "见证人授权有效期",
                        key: "witnessValidityAuthorization",
                        align: "center",
                    },
                    {
                        title: "状态",
                        key: "status",
                        slot: 'status',
                        align: "center",
                    }
                ],
                data: [],
                total: 0,
            }
        },
        mounted(){
            this.getWitnessList();
        },
        methods: {
            //搜索操作
            handleSearch() {
                this.searchForm.pageNumber = 1;
                this.searchForm.pageSize = 10;
                this.getWitnessList();
            },
            //获取见证人信息列表
            getWitnessList() {
                this.loading = true;
                this.searchForm.contractNo = this.detailParams.contractNo;
                getWitnessList(this.searchForm).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        this.data = res.data.records;
                        console.log(this.data)
                        this.total =res.data.total;
                    }
                });
            },
            changePage(v) {
                this.searchForm.pageNumber = v;
                this.getWitnessList();
                this.clearSelectAll();
            },
            clearSelectAll() {
                this.$refs.table.selectAll(false)
            },
            changePageSize(v) {
                this.searchForm.pageSize = v;
                this.getWitnessList();
            },
        }
    }
</script>

<style scoped>

</style>
